import PlatType from "./PlatTypes";
import Sdk_wx from "./Sdk_wx";
import SdkCode from "./SdkCode";
import ShareInfo from "./ShareInfo";

export default class SdkManager{
    private static _ins:SdkManager;
    public static get ins():SdkManager{
        if(!this._ins)this._ins=new SdkManager();
        return this._ins;
    }
    private mCurrSdkIns=null;
    constructor(){
        if(window["wx"]){
            this.mCurrSdkIns=new Sdk_wx();
            PlatType.currPalt=PlatType.wx;
        }
    }

    public getShowSplashAdStatus(func:Function){
        if(this.mCurrSdkIns)this.mCurrSdkIns.getShowSplashAdStatus(func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public showVideoAd(func:Function){
        if(this.mCurrSdkIns)this.mCurrSdkIns.showVideoAd(func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public showInterstitialAd(func:Function){
        if(this.mCurrSdkIns)this.mCurrSdkIns.showInterstitialAd(func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public showBannerAd(param,func:Function=null){
        if(this.mCurrSdkIns)this.mCurrSdkIns.showBannerAd(param,func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }


    public share(param=null,func:Function=null){
        if(this.mCurrSdkIns){
            let tparam = param?param:ShareInfo.getShareInfo(PlatType.currPalt);
            this.mCurrSdkIns.share(tparam,func);
        }
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public showShareMenu(func:Function=null){
        if(this.mCurrSdkIns)this.mCurrSdkIns.showShareMenu(func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public getShareInfo(func:Function=null){
        if(this.mCurrSdkIns)this.mCurrSdkIns.getShareInfo(func);
        else if(func)func(SdkCode.NOT_FIND_SDK_INS);
    }

    public getUserInfo(func:Function=null){
        if(this.mCurrSdkIns)this.mCurrSdkIns.getUserInfo(func);
        else if(func)func(null);
    }

    public login(func:Function=null){
        if(this.mCurrSdkIns)this.mCurrSdkIns.login(func);
        else if(func)func(null);
    }


    public postOpenMessage(data){
        if(this.mCurrSdkIns){
            this.mCurrSdkIns.postOpenMessage(data)
        }
    }

    public setUserCloudStorage(type:string,event:string,data){
        if(this.mCurrSdkIns){
            this.mCurrSdkIns.setUserCloudStorage(type,event,data);
        }
    }
}